//
//  XHQ_Define.h
//  Excellence
//
//  Created by 帝云科技 on 2017/6/16.
//  Copyright © 2017年 diyunkeji. All rights reserved.
//

#ifndef XHQ_Define_h
#define XHQ_Define_h

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//-------------------打印日志-------------------------
//DEBUG  模式下打印日志,当前行
#ifdef DEBUG
#   define XHQ_Log(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define XHQ_Log(...)
#endif


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----强弱引用------

//-----@weakify-----

#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif

//-----@strongify-----

#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//宽高

#define XHQ_iPhoneX ((kScreenWidth == 375.f && kScreenHeight == 812.f) ? YES : NO)
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define kTabBarHeight (XHQ_iPhoneX ? 83.f : 49.f)
#define kNavigationBarHeight 44.f
#define kStatusBarHeight (XHQ_iPhoneX ? 44.f : 20.f)
#define kStatusBarDifferenceHeight (kStatusBarHeight - 20.f)
#define kNavigationStatusHeight (kStatusBarHeight + kNavigationBarHeight)
#define kHomeIndicatorHeight (XHQ_iPhoneX ? 34.f : 0.f)

//屏幕适配宽高比例

#define BILIWIDTH(value) ((value)/375.0f * kScreenWidth)
#define BILIHEIGHT(value) BILIWIDTH(value)
//#define BILIHEIGHT(value) ((value)/667.0f * kScreenHeight)

//拼接字符串
#define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]

#define CountingDownNotiName @"startCountDown"
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//构建单例类
#define XHQ_SHARED_H(cls) +(instancetype)shared##cls;

#define XHQ_SHARED_M(cls) \
+ (instancetype)shared##cls { \
static cls *obj = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
    obj = [[cls alloc]init]; \
}); \
return obj; \
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//app版本号
#define BundleVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]


#define kFont(_SIZE) [UIFont systemFontOfSize:_SIZE]
#define kBlodFont(CGFolat) [UIFont boldSystemFontOfSize:BILIWIDTH(CGFolat)]


/// 图片
#define IMG(a) [UIImage imageNamed:a]

// 违章查询appkey
#define IllegalAPP_KEY @"d673d46d1388680b3b5a8d0200557117"

// 驾驶员计分appkey
#define DriveLicenseAPP_KEY @"731ee3e67e60ed6f250b7d9594cafe7e"


#define kUserDefaults   [NSUserDefaults standardUserDefaults]


/**
 防止重复调用
 */
#define kPreventRepeatClickTime(_seconds_) \
static BOOL shouldPrevent; \
if (shouldPrevent) return; \
shouldPrevent = YES; \
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((_seconds_) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ \
shouldPrevent = NO; \
}); \


#endif /* XHQ_Define_h */
